// 工作空间
<template>
  <div class="work_container">
    <el-row :gutter="15">
      <el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
        <!-- 用户 -->
        <div class="user_box">
          <div class="avatar">
            <img
              src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1936275246,3827590695&fm=26&gp=0.jpg"
              alt
            />
          </div>
          <div class="user_desc">
            <p class="user_name">admin</p>
            <p class="user_com" @click="selectVisible = true">{{selectProject.title}}</p>
            <p class="user_post">
              <el-tag effect="plain">项目经理</el-tag>
            </p>
          </div>
        </div>
        <!-- 统计 -->
        <div class="statistics">
          <div class="report_title" style="border:none;">快捷操作</div>
          <div class="statistics_row">
            <div class="statistics_item" @click="addDocument(1)">
              <img class="statistics_img" src="@/assets/images/home1.png" alt srcset />
              <p>晨会</p>
            </div>
            <div class="statistics_item" @click="addDayText(1)">
              <img class="statistics_img" src="@/assets/images/home2.png" alt srcset />
              <p>日报</p>
            </div>
            <div class="statistics_item">
              <img class="statistics_img" src="@/assets/images/home3.png" alt srcset />
              <p>周报</p>
            </div>
            <div class="statistics_item">
              <img class="statistics_img" src="@/assets/images/home4.png" alt srcset />
              <p>月报</p>
            </div>
            <div class="statistics_item">
              <img class="statistics_img" src="@/assets/images/home5.png" alt srcset />
              <p>总结</p>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <div class="calendar_box">
          <el-calendar class="calendar" v-model="dateValue"></el-calendar>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
        <div class="report_box">
          <div class="report_title">代办事项</div>
          <div class></div>
        </div>
      </el-col>
      <!-- 早会 -->
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <div class="report_box">
          <div class="report_title">工程早会</div>
          <el-row :gutter="15" class="report_col" v-for="(item,index) in morningList" :key="index">
            <el-col :span="16">
              <div class="report_row">
                <img src="@/assets/images/word.png" alt srcset />
                <p>{{item.title}}</p>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="report_time">{{item.date}}</div>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <!-- 日报 -->
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <div class="report_box">
          <div class="report_title">工程日报</div>
          <el-row :gutter="15" class="report_col" v-for="index in 5" :key="index">
            <el-col :span="18">
              <div class="report_row">
                <img src="@/assets/images/word.png" alt srcset />
                <p>昆明奥投科技消防器材安装早会</p>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="report_time">2018-08-09 07:56</div>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <!-- 周报 -->
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <div class="report_box">
          <div class="report_title">工程周报</div>
          <el-row :gutter="15" class="report_col" v-for="index in 5" :key="index">
            <el-col :span="18">
              <div class="report_row">
                <img src="@/assets/images/word.png" alt srcset />
                <p>昆明奥投科技消防器材安装早会</p>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="report_time">2018-08-09 07:56</div>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <!-- 月报 -->
      <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
        <div class="report_box">
          <div class="report_title">工程月报</div>
          <el-row :gutter="15" class="report_col" v-for="index in 5" :key="index">
            <el-col :span="18">
              <div class="report_row">
                <img src="@/assets/images/word.png" alt srcset />
                <p>昆明奥投科技消防器材安装早会</p>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="report_time">2018-08-09 07:56</div>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <!-- 我的工程 -->
      <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
        <div class="project_box">
          <div class="report_title" style="border:none;">我的工程</div>
          <div class="project_table">
            <el-table :data="tableData" stripe style="width: 100%">
              <el-table-column prop="date" label="工程名称" width="180"></el-table-column>
              <el-table-column prop="name" label="工程地址" width="180"></el-table-column>
              <el-table-column prop="address" label="责任书"></el-table-column>
              <el-table-column prop="address" label="设计方案"></el-table-column>
              <el-table-column prop="address" label="合同"></el-table-column>
              <el-table-column prop="address" label="流程节点"></el-table-column>
              <el-table-column prop="address" label="周期"></el-table-column>
              <el-table-column prop="address" label="创建日期"></el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                  <el-button
                    size="mini"
                    type="danger"
                    @click="handleDelete(scope.$index, scope.row)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-col>
    </el-row>
    <!-- 添加日志，报告模态框 -->
    <reportDialog :show.sync="dialogVisible" :modalData="modalForm"></reportDialog>
    <!-- 添加日报模态框 -->
    <dayTextDialog :show.sync="dayTextVisible" :modalData="datTextForm"></dayTextDialog>
    <!-- 选择项目模态框 -->
    <el-dialog title="提示" :visible.sync="selectVisible" width="70%" :before-close="handleClose">
      <el-table
        ref="singleTable"
        :data="tableData"
        highlight-current-row
        @current-change="handleCurrentChange"
        style="width: 100%"
      >
        <el-table-column type="index" width="50" label="#"></el-table-column>
        <el-table-column prop="title" label="工程名称" width="180"></el-table-column>
        <el-table-column prop="money" label="工程金额" width="150"></el-table-column>
        <el-table-column prop="address" label="工程地址" width="200"></el-table-column>
        <el-table-column prop="sjfa_title" label="设计方案" width="200"></el-table-column>
        <el-table-column prop="ysbz_title" label="验收标准" width="200"></el-table-column>
        <el-table-column prop="zrs_files" label="责任书" width="200"></el-table-column>
        <el-table-column prop="title" label="合同" width="200"></el-table-column>
        <el-table-column prop="create_time" label="创建日期" width="200"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="selectVisible = false">取 消</el-button>
        <el-button type="primary" @click="selectTable">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getProjectList, getMorningText } from "@/api/project";
import reportDialog from "@/components/project/addReport";
import dayTextDialog from "@/components/project/addDayText";
import editTextDialog from "@/components/project/addText";
export default {
  name: "work",
  components: { reportDialog, dayTextDialog, editTextDialog },
  data() {
    return {
      fileUrl: "http://192.168.101.192/shouhuzhe/public",
      tableData: [],
      currentRow: null,
      //选择项目模态框
      selectVisible: false,
      //当前页面表单
      selectProject: {
        title: "选择项目",
      },
      // 模态框参数
      modalForm: {
        addType: "",
      },
      // 添加日报模态框
      datTextForm: {
        opera: 1,
      },
      // 查询参数
      param: {
        title: "",
        page: "1",
        page_size: "100",
      },
      //添加日志报告模态框
      dialogVisible: false,
      dayTextVisible: false,
      //日历
      dateValue: new Date(),
      tableData: [],
      //早会日记
      morningList: [],
    };
  },
  created() {
    var that = this;
    that.getAllList();
  },
  mounted() {},
  methods: {
    //确定选择
    selectTable() {
      console.log(this.currentRow);
      this.selectProject = this.currentRow;
      this.selectVisible = false;
      this.getMorningList();
    },
    // 根据项目id获取早会列表
    async getMorningList() {
      var that = this;
      const res = await getMorningText({ project_id: that.selectProject.id });
      console.log(res);
      if (res.data) {
        that.morningList = res.data;
      }
    },
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    //关闭模态框
    handleClose(done) {
      this.selectVisible = false;
    },
    //获取项目列表
    async getAllList() {
      var that = this;
      const res = await getProjectList(that.param);
      console.log(res);
      if (res.data) {
        that.tableData = res.data;
      }
    },
    addDocument(event) {
      console.log("编辑文档");
      var that = this;
      that.modalForm.addType = event;
      that.dialogVisible = true;
      console.log(that.dialogVisible);
      console.log(that.modalForm);
    },
    //添加日报
    addDayText(event) {
      console.log(event);
      var that = this;
      that.datTextForm.opera = 1;
      that.dayTextVisible = true;
    },
  },
};
</script>
<style scoped lang="scss">
.report_box {
  height: 330px;
  background: #fff;
  margin-top: 15px;
  padding: 15px;
}
.report_col {
  margin-top: 10px;
}
.project_box {
  margin-top: 15px;
  height: 500px;
  background: #fff;
  padding: 15px;
}
.report_time {
  color: #999;
  font-size: 14px;
  line-height: 40px;
  height: 40px;
  text-align: right;
}
.report_row {
  color: #333;
  font-size: 17px;
  font-weight: 500;
  line-height: 40px;
  height: 40px;
  display: flex;
  flex-flow: row wrap;
  img {
    width: 30px;
    height: 30px;
    margin: 6px;
  }
  p {
    height: 40px;
    line-height: 40px;
  }
}
.statistics_item {
  height: auto;
  width: 80px;
  text-align: center;
  margin-left: 10px;
  .statistics_img {
    width: 70px;
    height: 70px;
  }
  p {
    color: #000;
    font-size: 15px;
  }
}
.report_title {
  font-size: 18px;
  color: #333;
  font-weight: 600;
  padding-left: 5px;
  padding-bottom: 10px;
  border-bottom: 1px solid #dbdbdb;
}
.work_container {
  background: #f6f8f9;
}
.calendar_box {
  padding: 15px;
  background: #fff;
  height: 400px;
  .calendar {
    height: 370px;
    overflow: auto;
  }
}
.statistics {
  height: 223px;
  margin-top: 15px;
  background: #fff;
  padding: 15px;
  .statistics_row {
    height: 100px;
    margin-top: 15px;
    display: flex;
    flex-flow: row wrap;
  }
}
.user_box {
  height: 160px;
  background: #fff;
  padding: 15px;
  display: flex;
  flex-flow: row wrap;
  .user_desc {
    padding-left: 15px;
    .user_name {
      font-size: 25px;
      font-weight: 600;
      color: #000;
    }
    .user_com {
      font-size: 18px;
      font-weight: 500;
      color: #333;
      line-height: 1.5em;
    }
  }
  .avatar img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: #f6f8f9;
  }
}
.work_item {
  border: 1px solid blue;
  height: 400px;
}
</style>
